package io.xxx.aurora.client.uv;

import io.netty.channel.Channel;
import io.xxx.aurora.client.uv.client.NettyClient;
import io.xxx.aurora.client.uv.protocol.RpcRequest;

import java.util.UUID;
import java.util.concurrent.TimeUnit;

/**
 * <uv> [2018/10/13 19:51]
 */
public class Main {

    public static void main(String[] args) throws Exception {
        NettyClient client = new NettyClient("127.0.0.1", 8081);
        //启动client服务
        client.start();

        Channel channel = client.getChannel();
        //消息体
//        RpcRequest request = new RpcRequest();
//        request.setId(UUID.randomUUID().toString());
//        request.setData("client.message");
//        //channel对象可保存在map中，供其它地方发送消息
//        channel.writeAndFlush(request);

        for (int i = 1; i <= 10; i++) {
//            RpcRequest req = new RpcRequest();
//            req.setId(UUID.randomUUID().toString());
//            req.setData("client.message");
//            channel.writeAndFlush(req);
            channel.writeAndFlush("Send: " + i);
            TimeUnit.SECONDS.sleep(1);
        }
        channel.closeFuture().sync();
    }
}
